import request from '@/utils/request';

export interface LoginParamsType {
  mobile?: string;
  smsVerificationCode?: string;
}

export interface userData {
  [as: string]: string | null | number;
}
export interface LoginData {
  responseCode: string;
  responseMessage: string;
  data?: userData;
}

/**
 * 登录
 * @param params
 */
export async function fakeAccountLogin(params: LoginParamsType): Promise<LoginData> {
  return request('/sealCuttingApi/login/signIn', {
    method: 'POST',
    data: params,
  });
}

/**
 * 登录效验用户是否存在
 * @param params
 */
export async function checkMobile(params: LoginParamsType) {
  return request('/sealCuttingApi/login/checkMobile', {
    params: params,
  });
}

/**
 * 登录获取验证码
 * @param params
 */
export async function sendMobileSmsVerificationCode(params: LoginParamsType) {
  return request('/sealCuttingApi/login/sendMobileSmsVerificationCode', {
    method: 'POST',
    data: params,
  });
}

/**
 * 退出登录
 */
export async function logout(): Promise<LoginData> {
  return request('/sealCuttingApi/login/logout');
}

interface userInfoId {
  id: number;
}

/**
 * 
  获取当前用户登录详情接口
 */
export async function queryCurrentUserInfo(params: userInfoId): Promise<LoginData> {
  // return request('/sealCuttingApi/user/queryCurrentUserInfo', {
  return request('/sealCuttingApi/user/queryUserInfo', {
    params,
  });
}
